<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<base href="<?php echo base_url(); ?>"/> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chi tiết đặt phòng</title>
<link rel="stylesheet" href="resources/admin/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="resources/admin/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="resources/admin/css/invalid.css" type="text/css" media="screen" />	
<link rel="stylesheet" href="resources/admin/css/south-street/jquery-ui-1.9.2.custom.min.css" type="text/css" />
<script type="text/javascript" src="resources/admin/scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="resources/admin/scripts/simpla.jquery.configuration.js"></script>
<script type="text/javascript" src="resources/admin/scripts/facebox.js"></script>
<script type="text/javascript" src="resources/admin/scripts/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="resources/admin/scripts/jquery.datePicker.js"></script>
<script type="text/javascript" src="resources/admin/scripts/jquery.date.js"></script>
<script type="text/javascript" src="resources/admin/scripts/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="resources/admin/scripts/js/jquery-ui-1.9.2.custom.js"></script>
<script type="text/javascript">
  $(function()
  {
		$( "#search-input" ).autocomplete(
		{
			source: function (request, response)
			{
				$.ajax(
				{
					url: "index.php/phieudatphong/LayPhieuDatPhong_ajax",
					type: 'POST',
					dataType: "json",
					data: 
					{
                        style: "full",
                        maxRows: 12,
                        name_startsWith: request.term
                    },					
					success: function(msg)
					{
						response($.map(msg, function(item)
						{
							return {label: item.Ten, value: item.Ten};
						}));
					}
				});
			},
			minLength: 2
	    });
  });
  
	function clearText(field)
	{
    	if (field.defaultValue == field.value) field.value = '';
	    else if (field.value == '') field.value = field.defaultValue;
	}
</script>
</head>
	<body><div id="body-wrapper"> <!-- Wrapper for the radial gradient background -->
		
		<div id="sidebar"><div id="sidebar-wrapper"> <!-- Sidebar with logo and menu -->
			
			<h1 id="sidebar-title"><a href="#">Simpla Admin</a></h1>
		  
			<!-- Logo (221px wide) -->
			<a href="#"><img id="logo" src="resources/admin/images/logo.png" alt="Simpla Admin logo" /></a>
		  
			<!-- Sidebar Profile links -->
			<div id="profile-links">
				Chào, <a href="#" title="Xem thông tin cá nhân"><?php echo $current_username; ?></a><br />
				<br />
				<a href="index.php/home/index" title="Xem trang i12" target="_blank">Xem Trang chủ</a> | <a href="index.php/login/logoutadmin" title="Đăng xuất">Thoát</a>
			</div>        
			
			<ul id="main-nav">  <!-- Accordion Menu -->
			<?php
				if($chucvu == 'Nhân viên' || $chucvu == 'Quản lý' || $chucvu == 'Admin')
				echo
						"<li>
							<a href='index.php/phieudatphong/admin_index' class='nav-top-item no-submenu current'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Đặt phòng
							</a>       
						</li>
				
						<li>
							<a href='#' class='nav-top-item'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Khách sạn
							</a>
							<ul>
								<li><a href='index.php/phongtrongtheongay/admin_index'>Quản lý phòng trống</a></li>                    
								<li><a href='index.php/khachsan/admin_index'>Quản lý khách sạn</a></li>                        
								<li><a href='index.php/loaiphong/admin_index'>Quản lý loại phòng</a></li> <!-- Add class 'current' to sub menu items also -->
								<li><a href='index.php/loaigiuong/admin_index'>Quản lý loại giường</a></li>
							</ul>                           
						</li>
				
						<li>
							<a href='#' class='nav-top-item '> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Khuyến mãi
							</a>    
							<ul>
								<li><a href='index.php/thongtinkhuyenmai/admin_index'>Quản lý thông tin KM</a></li>                    
								<li><a href='index.php/thekhuyenmai/admin_index'>Quản lý thẻ KM</a></li> 
							</ul>                                                  
						</li>";
				
				if($chucvu == 'Quản lý' || $chucvu == 'Admin')
					echo
						"<li>
							<a href='#' class='nav-top-item'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Nhà cung cấp
							</a> 
								<ul>                 
									<li><a href='index.php/nhacungcap/admin_index'>Nhà cung cấp hiện hành</a></li>
									<li><a href='index.php/nhacungcap/dangkymoi'>Danh sách đăng ký mới</a></li>
									<li><a href='index.php/nhacungcap/nccduyet'>Duyệt đăng ký</a></li>   
									<li><a href='index.php/nhacungcap/ngunghoptac'>Nhà cung cấp ngừng hợp tác</a></li>      
								</ul>         
						</li>
				
						<li>
							<a href='#' class='nav-top-item'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Báo cáo thống kê
							</a>
								<ul>                 
									<li><a href='index.php/baocao/admin_index'>Thống kê doanh thu</a></li>
									<li><a href='index.php/baocao/baocaokhachsan'>Thống kê khách sạn</a></li>
								</ul>       
						</li>";
                
				if($chucvu == 'Admin')
					echo
						"<li>
							<a href='#' class='nav-top-item'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Người dùng
							</a>
								<ul>                 
									<li><a href='index.php/nguoidung/admin_index'>Người dùng hiện hành</a></li>
									<li><a href='index.php/nguoidung/NDDisable'>Người dùng disabling</a></li>
								</ul>        
						</li>
						<li>
							<a href='index.php/hethong/admin_index' class='nav-top-item no-submenu'> <!-- Add the class 'no-submenu' to menu items with no sub menu -->
								Hệ thống
							</a>       
						</li>";
			?>
                
			</ul> <!-- End #main-nav -->
			
		</div></div> <!-- End #sidebar -->
		
		<div id="main-content"> <!-- Main Content Section with everything -->
			
			<noscript> <!-- Show a notification if the user has disabled javascript -->
				<div class="notification error png_bg">
					<div>
						Javascript is disabled or is not supported by your browser. Please <a href="http://browsehappy.com/" title="Upgrade to a better browser">upgrade</a> your browser or <a href="http://www.google.com/support/bin/answer.py?answer=23852" title="Enable Javascript in your browser">enable</a> Javascript to navigate the interface properly.
					</div>
				</div>
			</noscript>
			
			<!-- Page Head -->
            <div style="float:left; height:150px; width:55%; margin-top:10px; margin-bottom:20px;">
				<h2>Xin chào, <?php echo $current_username ?></h2>
				<p id="page-intro">Một ngày làm việc vui vẻ nhé !</p>
                <br />
                <br />

                <?php 
					echo form_open('phieudatphong/Tim');
                
					if(!$key)
					{
             			echo   "<fieldset>
									<input type='text' name='key' id='search-input' onfocus='clearText(this)' onblur='clearText(this)' class='text-input search-input' value='Nhập Mã đặt phòng hoặc Số điện thoại...' />  
			    	            	<input type='submit' class='button' value='Tìm' />
            				    </fieldset>";                
					}
					else
					{
             			echo   "<fieldset>
									<input type='text' name='key' id='search-input' class='text-input search-input' value='$key' />  
			    	            	<input type='submit' class='button' value='Tìm' />
            				    </fieldset>";						
					}
					
					echo form_close(); 
				?>
            </div>
            <div style="float:right;">
            	<img src="resources/admin/images/i12.png" />
            </div>
			
			<div class="clear"></div> <!-- End .clear -->
			
			<div class="content-box"><!-- Start Content Box -->
				
				<div class="content-box-header">
					
					<h3>Thông tin chi tiết phiếu đặt phòng</h3>
					
					<div class="clear"></div>
					
				</div> <!-- End .content-box-header -->
				
				<div class="content-box-content">
					
					<div class="tab-content default-tab" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
											
                        	<!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
                            
                       	<?php
							if($phieudatphong)
							{
								foreach($phieudatphong as $row)
								{
									$mapd = $row->MaPD;
									$email = $row->Email;
									$dienthoai = $row->DienThoai;
									$ngaydat = date("d/m/Y",strtotime($row->NgayDatPhong));
									$tongtien = number_format($row->TongTien * 1000, 0, '', '.')." VNĐ";
									$tinhtrang = $row->TinhTrangThanhToan;
									$gionhanphong = $row->GioNhanPhong;
									$ghichu = $row->GhiChu;
									$phantramgiam = $row->PhanTramGiam;
									$sothe = $row->SoThe;
									$malp = $row->LoaiPhong;											
									$loaiphong = $row->TenLoaiPhong;
									$maks = $row->MaKS;
									$khachsan = $row->TenKhachSan;
									$VAT = $row->VAT / 100;
									$phidichvu = $row->PhiDichVu * 1000;
											
									$tt = "<span style='color:green'>Đã thanh toán</span>";
									if($tinhtrang == -1)
										$tt = "<span style='color:red'>Hủy</span>";
									else if($tinhtrang == 0)
										$tt = "<span style='color:orange'>Chưa thanh toán</span>";

									echo "<table>
											<tr>
												<td style='width:150px;'><b>Mã phiếu đặt:</b></td>
												<td>$mapd</td>
											</tr>
											<tr>
												<td><b>Tình trạng thanh toán:</b></td>
												<td>$tt</td>
											</tr>
											<tr>
												<td><b>Email:</b></td>
												<td>$email</td>
											</tr>
											<tr>
												<td><b>Số điện thoại:</b></td>
												<td>$dienthoai</td>
											</tr>
											<tr>
												<td><b>Ngày đặt phòng:</b></td>
												<td>$ngaydat</td>
											</tr>
											<tr>
												<td><b>Giờ nhận phòng:</b></td>
												<td>$gionhanphong giờ</td>
											</tr>
											<tr>
												<td><b>Khách sạn:</b></td>
												<td><a href='index.php/khachsan/XemChiTiet/$maks' title='Xem thông tin khách sạn'>$khachsan</a></td>
											</tr>
											<tr>
												<td><b>Loại phòng:</b></td>
												<td><a href='index.php/loaiphong/MoTrangCapNhat/$malp' title='Xem thông tin loại phòng'>$loaiphong</a></td>
											</tr>												
										</table>";
								}
							}
						?>
                        
                        <br />
                        
                        <?php
                        	if($chitietphieudat)
							{
								$str = "";
								$songay = count($giathuetheongay);
								$sophong = 0;
								
								$today = date("Y-m-d");
								$firstday = "";
								foreach($chitietphieudat as $row1)
								{
                                 	$sophong++;
									$loaigiuong = $row1->Ten;
									$songuoilon = $row1->SoNguoiLon;
									$sotreem = $row1->SoTreEm;
									$sotienthemnguoi = $row1->SoTienThemNguoi * 1000;
									$tenkhach = $row1->HoTenNguoiDaiDien;
									  
                                    $str = $str . "<tr>
				                                    	<td rowspan='$songay'><b>Phòng $sophong - $tenkhach</b><br />
                	                        				Loại giường: $loaigiuong<br />                                        
                    	                    				Số người lớn: $songuoilon<br />
                        	                                Số trẻ em: $sotreem<br /></td>";
								
									$i = 0;
									foreach($giathuetheongay as $row2)
									{
										$i++;
										
										$ngaythue = date("d/m/Y",strtotime($row2->Ngay));
										$giathue = $row2->Gia * 1000;										
										$gia = number_format($giathue, 0, '', '.')." VNĐ";
										$phithem = $VAT*$giathue + $phidichvu + $sotienthemnguoi;
										$phi = number_format($phithem, 0, '', '.')." VNĐ";
										$thanhtien = number_format($giathue + $phithem, 0, '', '.')." VNĐ";
										
										if($i == 1)
										{
											$str = $str . "<td>$ngaythue</td>
					                                    	<td>$gia</td>
                                    						<td>$phi</td>
                                    						<td>$thanhtien</td>                                                                                                                                                                
                                    					</tr>";
											$firstday = $row2->Ngay;														
										}
										else
											$str = $str . "<tr>
					                                    	<td>$ngaythue</td>
					                                    	<td>$gia</td>
                                    						<td>$phi</td>
                                    						<td>$thanhtien</td>                                                                                                                                                                
                    					                </tr>";
									}									
								}
                                    
								$str = $str . "<tr style='border-top:#CCC solid; border-width:0.5px;'>
                                    				<td><strong>Thẻ khuyến mãi</strong>: $sothe</td>
			                                        <td><strong>Phần trăm giảm</strong>: $phantramgiam%</td>
            			                            <td></td>
                        			                <td><strong>Tổng số tiền:</strong></td>
                                    			    <td><strong>$tongtien</strong></td>
			                                    </tr>";
								
                                echo "<table>
                                			<thead>
		    	                            	<tr>
        	    		                        	<th>Chi tiết phòng</th>
                        			                <th>Ngày</th>
                                    			    <th>Giá căn bản</th>
			                                        <th>VAT & Phí*</th>
            			                            <th>Thành tiền</th>                          
                        			            </tr>
                                    		</thead>" . $str . "</table><br />";
											
								$today_time = strtotime($today);
								$firstday_time = strtotime($firstday);
								
								if($today_time < $firstday_time)
									echo "<br />
											<p>
												<a class='button' href='index.php/phieudatphong/MoTrangCapNhat/$mapd' />Thay đổi thông tin</a>
											</p>";										
   							}
						?>
                            
							<div class="clear"></div><!-- End .clear -->
						
					</div> <!-- End #tab1 -->       
					
				</div> <!-- End .content-box-content -->
				
			</div> <!-- End .content-box -->
			
			<div id="footer">
				<small> <!-- Remove this notice or replace it with whatever you want -->
						&#169; Copyright 2012 i12 Online Booking | Powered by <a href="http://themeforest.net/item/simpla-admin-flexible-user-friendly-admin-skin/46073">Simpla Admin</a> | <a href="#">Top</a>
				</small>
			</div><!-- End #footer -->
			
		</div> <!-- End #main-content -->
	</div></body>
</html>
